<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

/**
 * Adsense backyard_view
 *
 * Authentication library for Code Igniter.
 * 
 * @author		Ryan Hu
 * @version		1.0
 */
class Backyard_view
{
	private $error = array();

	function __construct()
	{
		$this->ci =& get_instance();
		$this->ci->load->helper('url');
		$this->ci->load->config('backyard_view', TRUE);

		$this->ci->load->library('session');
		//$this->ci->load->database();
		$this->ci->load->library('tank_auth');
		//$this->ci->load->model('tank_auth/users');

		// Try to autologin
		//$this->autologin();
	}

	/**
	 * backyard header
	 */
	function header()
	{
		$data = array();
		if($this->ci->tank_auth->is_logged_in()){
			$user_role = $this->ci->session->userdata('role');
			
			$data['navigation'] = $this->ci->config->item('navigation_'.$user_role, 'backyard_view');
			$data['navigation_selected'] = $this->ci->uri->segment(1, 'summary');
			$data['is_login'] = TRUE;
			
		}
		else{
			$data['navigation'] = array();
			$data['navigation_selected'] = '';
			$data['is_login'] = FALSE;
		}
		/*
		 * make url parameter into associated structure 
		 */
		foreach($this->ci->uri->uri_to_assoc(1) as $key=>$val){
			$data[$key] = $val;
		}
		//echo "<pre>";print_r($data);echo "</pre>";
		$this->ci->load->view('adsense/header', $data);
	}

	/**
	 * backyard footer
	 */
	function footer()
	{
		$this->ci->load->view('adsense/footer');
	}

	
}

/* End of file Backyard_view.php */
/* Location: ./application/libraries/Backyard_view.php */